package com.ujoku.interceptor.admin.oa;

import com.ujoku.domain.admin.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by Administrator on 14-11-1.
 */
public class OAAuthenticationInterceptor extends HandlerInterceptorAdapter {

    private static final Logger log = LoggerFactory.getLogger(OAAuthenticationInterceptor.class);

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.debug("OAAuthenticationInterceptor-->preHandle, URI" + request.getRequestURI());
        User userData = (User) request.getSession().getAttribute("user");

        if(userData == null)
        {
            response.sendRedirect("/oa-expired");
            //throw new LoginRequiredException("请先登录!");
        }

        return true;
    }


}
